﻿using DingChiServiceApp.db;
using DingChiServiceApp.entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DingChiServiceApp
{
    public class UpStatusJsonDao :JsonDao<UpStatus>
    {
        private static UpStatusJsonDao _instance;
        public static UpStatusJsonDao Instance
        {
            get
            {
                if (_instance == null)
                {
                    _instance = new UpStatusJsonDao();
                }
                return _instance;
            }
        }

        public  UpStatus  FindByTableName( string tableName)
        {
            var d = Datas.Find(i => i.tableName.Equals(tableName));
            if(d == null)
            {
                d = new UpStatus()
                {
                    id = (long)DateTime.Now.Millisecond,
                    tableName = tableName,
                    createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    updateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    lastUpTime = "2023-04-20 00:00:01",
                };
                Insert(d);
            }        
            return d;
        }
    }
}
